<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('机构考勤统计列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input type="hidden" name="checkingType" th:value="${checkingType}"/>
                <div class="select-list">
                    <ul>
                        <li>
                            <label>机构名称：</label>
                            <input type="text" name="deptName"/>
                        </li>
                        <li class="select-date">
                            <label>打卡时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="statistics:deptChecking:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "statistics/deptChecking";

    $(function () {
        var options = {
            url: prefix + "/list",
            exportUrl: prefix + "/export",
            pagination: false,
            modalName: "机构考勤统计",
            columns: [{
                checkbox: true
            },
                {
                    field: 'deptId',
                    title: '部门id',
                    visible: false
                },
                {
                    field: 'deptName',
                    title: '机构名称'
                },
                {
                    field: 'sumNums',
                    title: '累计打卡'
                },
                {
                    field: 'checkInfo',
                    title: '打卡说明',
                    formatter: function (value, row, index) {
                        return checkInfo(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="detail(\'' + row.deptId + '\')"><i class="fa fa-list-ul"></i>详情</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /*字典列表-详细*/
    function detail(deptId) {
        var url = ctx + "statistics/userChecking/" + deptId;
        $.modal.openTab("用户考勤统计", url);
    }

    function checkInfo(value) {
        if (value == "") {
            return "";
        } else {
            return value.replaceAll("。", "</br>");
        }

    }
</script>
</body>
</html>